Skip to content

feat(spans): enforce max segment bytes during ingestion#112561

Merged
lvthanh03 merged 4 commits intomasterfrom
tony/bound-segments
Apr 9, 2026
Merged

feat(spans): enforce max segment bytes during ingestion#112561
lvthanh03 merged 4 commits intomasterfrom
tony/bound-segments

Conversation

@lvthanh03
Copy link
Copy Markdown
Member

@lvthanh03 lvthanh03 commented Apr 9, 2026

Refs STREAM-859

We want to able to skip merging further subsegments into the set but we don't want to drop data. So naturally, a subsegment not being merged into its set have to become its own separate segment.

  • Adds the spans.buffer.enforce-segment-size option to force segment size limit of max-segment-bytes.
  • When the option is enabled:
    • The Lua script checks cumulative ingested bytes of the target set to decide whether to merge or not.
    • Writes each subsegment's payloads to a separate key determined by a random salt. This is to prevent dropping overflow subsegments when we decide not to merge them into the target set. Each subsegment not being merged will become its own separate segment, and we add a new key in the queue based on the salt value above.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2026
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 9, 2026

@lvthanh03 lvthanh03 marked this pull request as ready for review April 9, 2026 15:52
@lvthanh03 lvthanh03 requested review from a team as code owners April 9, 2026 15:52
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6fff2a5. Configure here.

Comment thread src/sentry/scripts/spans/add-buffer.lua
Copy link
Copy Markdown
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@lvthanh03 lvthanh03 merged commit f64843b into master Apr 9, 2026
77 checks passed
@lvthanh03 lvthanh03 deleted the tony/bound-segments branch April 9, 2026 19:18
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
Refs STREAM-859

We want to able to skip merging further subsegments into the set but we
don't want to drop data. So naturally, a subsegment not being merged
into its set have to become its own separate segment.
- Adds the `spans.buffer.enforce-segment-size` option to force segment
size limit of `max-segment-bytes`.
- When the option is enabled:
- The Lua script checks cumulative ingested bytes of the target set to
decide whether to merge or not.
- Writes each subsegment's payloads to a separate key determined by a
random salt. This is to prevent dropping overflow subsegments when we
decide not to merge them into the target set. Each subsegment not being
merged will become its own separate segment, and we add a new key in the
queue based on the salt value above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants